package com.teacold.customdemo.customview;

import android.content.Context;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import android.widget.FrameLayout;

public class ItemLongClickMaskHelper {
    private FrameLayout mRootFrameLayout;
    private TFZHLayout mTFZHLayout;
    private Context mContext;
    private ScaleAnimation animation;
    private String productId;

    public ItemLongClickMaskHelper(final Context mContext) {
        this.mContext = mContext;
        mTFZHLayout=new TFZHLayout(mContext);
        animation=new ScaleAnimation(0f,1.0f,1.0f,1.0f, Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
        animation.setDuration(100);
    }
    public ItemLongClickMaskHelper setRootFrameLayout(FrameLayout frameLayout){
        if (mRootFrameLayout != null){
            mRootFrameLayout.removeView(mTFZHLayout);
        }
        mRootFrameLayout = frameLayout;
        mRootFrameLayout.addView(mTFZHLayout);
        mTFZHLayout.startAnimation(animation);
        return this;
    }

    public ItemLongClickMaskHelper setMaskItemListener(TFZHLayout.TFLongClickListener listener){
        this.mTFZHLayout.setTFLongClickListener(listener);
        return this;
    }




    /**
     * 遮罩消失
     */
    public void dismissItemMaskLayout(){
        if (mRootFrameLayout != null){
            mRootFrameLayout.removeView(mTFZHLayout);
        }
    }

}
